package com.henu.xyh;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ImageView;

import com.henu.R;
import com.henu.yizhiya.LoginActivity;

public class SplashActivity extends AppCompatActivity {

    private ImageView img;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        img= (ImageView) findViewById(R.id.sp_img);
        MyThread thread=new MyThread();
        thread.start();
    }
    int i=0;
    class MyThread extends Thread {
        public void run() {
            while (i < 3) {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if(i==0)
                        {
                            img.setBackgroundResource(R.mipmap.sp_image_a);
                        }
                        else if(i==1)
                        {
                            img.setBackgroundResource(R.mipmap.duanwu);

                        }
                        else if(i==2)
                        {
                            Intent intent = new Intent(SplashActivity.this, LoginActivity.class);
                            startActivity(intent);
                            finish();
                        }
                    }
                });
                try {
                    sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                i++;
            }
        }
    }
}
